package com.app.view.component.room.chips 
{
	import flash.geom.Point;
	import flash.display.MovieClip;
	
	import com.greensock.TweenLite;
	
	import com.peachcastle.core.Display;
	
	import com.peachcastle.debug.Log;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class ChipsManager extends Display 
	{
		
		private static const SEAT_MAX_COUNT:int = 8;
		
		private var _usersChips:Array = null;	// 用户筹码
		
		public function ChipsManager(ui:MovieClip = null) 
		{
			super(ui);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			
			_usersChips = [];
			for (var i:int = 1; i <= SEAT_MAX_COUNT; i++)
			{
				_usersChips[i] = new ChipsView(assest["chips" + i]);	
			}
		}
		
		/**
		 * 显示用户筹码
		 * @param	seatId
		 * @param	chipsCount
		 */
		public function showUserChips(seatid:int, chips:int):void
		{
			(_usersChips[seatid] as ChipsView).showChips(chips);	
		}
		
		public function moveSeatToSeat(fSeatid:int, sSeatid:int, chips:int):void
		{
			TweenLite.to(ChipsView(_usersChips[fSeatid]).assest, 1, { x: ChipsView(_usersChips[sSeatid]).assest.x, y: ChipsView(_usersChips[sSeatid]).assest.y, onComplete:moveResult, onCompleteParams:[sSeatid, chips, fSeatid]});
		}
		
		private function moveResult(sSeatid:int, chips:int, fSeatid:int):void
		{
			ChipsView(_usersChips[fSeatid]).reset();
			ChipsView(_usersChips[fSeatid]).hideAssest();
			showUserChips(sSeatid, chips);
		}
		
		public function clearAllChips():void
		{
			for (var i:int = 1; i <= SEAT_MAX_COUNT; i++)
			{
				(_usersChips[i] as ChipsView).showChips(0);
			}
		}
	}

}